home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
swagn_r.zip
/
NUMBERS.SWG
/
0064_Unit to handle bit operations.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-03
|
915b
|
36 lines
{ Ok Here is a nice little unit to handle bit operations. }
UNIT Bits;
INTERFACE
function CheckBit(bit_number : byte; byte_on : byte) : boolean;
function ChangeBit(bit_number : byte; byte_on : byte) : byte;
function BitON(bit_number : byte; byte_on : byte) : byte;
function BitOFF(bit_number : byte; byte_on : byte) : byte;
IMPLEMENTATION
const
test : array[0..7] of byte = (1,2,4,8,$10,$20,$40,$80);
function CheckBit(bit_number : byte; byte_on : byte) : boolean;
begin
CheckBit := byte_on and test[bit_number] <> 0
end;
function ChangeBit(bit_number : byte; byte_on : byte) : byte;
begin
ChangeBit := byte_on xor test[bit_number]
end;
function BitON(bit_number : byte; byte_on : byte) : byte;
begin
BitON := byte_on or test[bit_number]
end;
function BitOFF(bit_number : byte; byte_on : byte) : byte;
begin
BitOFF := byte_on and not test[bit_number]
end;
end.